<template>
	<view>
		<view class="bus_info tp-w690">
			<view class="info_top-wrap">
				<view class="date">
					<text class="type">拼车</text>
					拼车时间：{{dateInfo.time}}
				</view>
				<view class="status">
					<view v-if="curNavbar.alias!=='noTraveling' && curNavbar.alias!=='traveled' && curNavbar.alias!=='addOrder' && curNavbar.alias!=='cancelled'">{{curNavbar.name}}</view>
					<view v-if="curNavbar.alias==='traveled'">{{dateInfo.statusDetail}}</view>
					<!-- <view v-if="curNavbar.alias==='traveled' && dateInfo.status==5">待评价</view> -->
					<view v-if="curNavbar.alias==='noTraveling' && dateInfo.status==2">未出行</view>
					<view v-if="curNavbar.alias==='noTraveling' && dateInfo.status==3">进行中</view>
					<view v-if="curNavbar.alias==='noTraveling' && dateInfo.status==4">出行中</view>
					<view v-if="curNavbar.alias==='noTraveling' && dateInfo.status==10">已超时</view>
					<view v-if="curNavbar.alias==='cancelled'">已退款</view>
					<view v-if="curNavbar.alias==='addOrder'">{{dateInfo.statusDetail}}</view>
				</view>
			</view>

			<view class="info_content-wrap" @click="handleGoRentOrderDetail(dateInfo)">
				<view class="address-wrap">
					<view class="step-wrap">
						<view class="dot dot_from"></view>
						<view class="dot dot_to"></view>
					</view>
					<view class="from">
						<text class="txt ellispsis1">{{dateInfo.startStation}}</text>
					</view>
					<view class="to">
						<text class="txt ellispsis1">{{dateInfo.endStation}}</text>
					</view>
				</view>
				<view class="price" v-if="curNavbar.alias==='addOrder'"><text style="font-size: 24rpx;">￥</text> {{dateInfo.price}}</view>
				<view class="price" v-else><text style="font-size: 24rpx;">￥</text> {{dateInfo.price}}</view>
			</view>

			<view class="order_info-wrap">
				<view class="order_num">订单号：{{dateInfo.orderNo}}</view>
				<view class="btns">
					<!-- <view v-if="(curNavbar.alias === 'noTraveling' && dateInfo.status != 4) && curNavbar.alias!=='processing' && curNavbar.alias!=='cancelled' && curNavbar.alias!=='addOrder' && curNavbar.alias!=='traveled' "  class="btn cancle" @click="handleCancleOrder" >取消订单</view> -->
					<view v-if="[0,1,2,3].includes(dateInfo.status-0)" class="btn cancle" @click="handleCancleOrder">取消订单</view>
					<view v-if="[5].includes(dateInfo.status-0)" class="btn pay" @click="handleScore">打分评价</view>
					<view v-if="[6].includes(dateInfo.status-0)" class="btn pay" @click="handleLookScore">查看评价</view>
					<view v-if="[0].includes(dateInfo.status-0)" class="btn pay" @click="handlePay">支付</view>
					<view v-if="[8].includes(dateInfo.status-0)" class="btn pay" @click="handlePay">支付￥{{dateInfo.waitPay}}</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import utils from '../../utils/utils.js'
	export default {
		components: {},
		props: {
			dateInfo: {
				type: Object,
				default () {
					return {}
				}
			},
			curNavbar: {
				type: [Object, Boolean],
				default () {
					return false
				}
			}
		},
		data() {
			return {
				alertConfig: {
					cancleText: '我再想想',
					confirmText: '确定取消',
					content: '是否取消订单'
				},
				cancleOrderShouldPayMoney: 0,
			};
		},
		mounted() {

		},
		computed: {
			info() {
				return this.dateInfo
			}
		},
		methods: {
			handlePay() {
				if (this.curNavbar.alias == 'toBePaid' && !utils.getCountDownTime(this.dateInfo.time)) { // 待支付订单超时
					uni.navigateTo({
						url: '../../pagesUser/order/carpool.orderDetail?orderStatus=' + this.curNavbar.alias + '&id=' + this.dateInfo.orderNo
					});
				} else {
					const _this = this
					if (_this.dateInfo.status == 8) {
						_this.$store.commit('upOrderPayType', 'carpoolAdd')
						uni.$emit('showCommonPayZhui', _this.dateInfo)
					} else {
						// #ifdef MP-WEIXIN
						uni.requestSubscribeMessage({
							tmplIds: ['jT4idTW1Jb_UNM1PI2mPSIttc26qnirW8LGuH_kjx7s'],
							success(res) {
								_this.submitWxNotifyConfirm('jT4idTW1Jb_UNM1PI2mPSIttc26qnirW8LGuH_kjx7s', res[
									'jT4idTW1Jb_UNM1PI2mPSIttc26qnirW8LGuH_kjx7s'])
								// #endif
								uni.$emit('showCommonPay', _this.dateInfo)
								// #ifdef MP-WEIXIN
							}
						})
						// #endif
					}
				}
			},
			handleCancleOrder() {
				uni.$emit('cancleOrder', this.dateInfo)
			},
			handleGoRentOrderDetail(data) {
				uni.navigateTo({
					url: '../../pagesUser/order/carpool.orderDetail?orderStatus=' + this.curNavbar.alias + '&id=' + data.orderNo
				});
			},
			handleScore() { // 打分评价
				uni.$emit('readyEval', this.dateInfo)
			},
			handleLookScore() {
				uni.navigateTo({
					url: '../../pagesUser/busTravelEvaluation?id=' + this.dateInfo.orderNo
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.bus_info {
		background: #fff;
		border-radius: 12rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		margin-bottom: 20rpx;

		.info_top-wrap {
			height: 80rpx;
			display: flex;
			align-items: center;
			font-size: 26rpx;
			justify-content: space-between;
			padding: 0 20rpx;

			.date {
				color: #666;
				display: flex;
				align-items: center;

				.type {
					display: inline-block;
					width: 66rpx;
					height: 40rpx;
					line-height: 40rpx;
					text-align: center;
					background-color: #FFF2E0;
					color: $yellow;
					font-size: 22rpx;
					margin-right: 20rpx;
					border-radius: 8rpx;
				}
			}

			.status {
				color: $yellow;
			}
		}

		.info_content-wrap {
			display: flex;
			flex: 1;
			align-items: center;
			justify-content: space-between;
			padding: 20rpx;
			border-top: 1px solid #ebebeb;
			border-bottom: 1px solid #ebebeb;

			.address-wrap {
				display: flex;
				flex: 1;
				flex-direction: column;
				justify-content: space-between;
				font-size: 30rpx;
				font-weight: bold;
				position: relative;

				.step-wrap {
					display: flex;
					justify-content: space-between;
					flex-direction: column;
					height: 90rpx;
					position: absolute;
					top: 6rpx;
					left: 0rpx;

					&::before {
						content: '';
						position: absolute;
						left: 50%;
						transform: translateX(-50%);
						height: 100%;
						width: 1px;
						background-color: #ccc;
					}

					.dot {
						height: 20rpx;
						width: 20rpx;
						border: 1px solid #ccc;
						border-radius: 50%;
						position: relative;

						&::before {
							content: '';
							position: absolute;
							left: 50%;
							top: 50%;
							transform: translate(-50%, -50%);
							height: 100%;
							width: 100%;
							border-radius: 50%;
							background-color: #fff;
						}
					}
				}

				.from,
				.to {
					display: flex;
					align-items: center;
					padding-left: 44rpx;

					.type {
						padding: 0 10rpx;
						background-color: #FFF2E0;
						color: $yellow;
						font-size: 22rpx;
						border-radius: 8rpx;
						margin-right: 20rpx;
						height: 40rpx;
						line-height: 40rpx;
						text-align: center;
					}
				}

				.from {
					margin-bottom: 20rpx;
				}
			}

			.price {
				color: $red;
				font-size: 36rpx;
				font-weight: bold;
			}
		}

		.order_info-wrap {
			height: 95rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			color: #666;
			padding: 0 20rpx;

			.order_num {
				font-size: 26rpx;
			}

			.btns {
				display: flex;
				align-items: center;
				justify-content: flex-end;

				.btn {
					border-radius: 12rpx;
					padding: 0 15rpx;
					height: 56rpx;
					line-height: 56rpx;
					text-align: center;
					min-width: 78rpx;
					font-size: 28rpx;

					&.cancle {
						background-color: #EBEBEB;
					}

					&.pay {
						color: #fff;
						background-color: $blue;
						margin-left: 20rpx;
					}
				}
			}
		}
	}
</style>
